/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2022-12-15
 * Time: 16:26
 */
public class test {
    public static void main(String[] args) {
        String aa = "vbyytoijnbgtyrjlsc";
        Solution solution = new Solution();
        int q=solution.getLucky(aa,2);
        System.out.println(q);
    }
}

class Solution {
    public int getLucky(String s, int k) {

        int[] arr = new int[s.length()];
        int sum1 = 0;
        for (int i = 0; i < arr.length; i++) {
            int n=0;
            n= s.charAt(i) - 'a' + 1;
            while (n>0){
                sum1+=(n%10);
                n/=10;
            }
        }
        int a = sum1;
        if(k==1){
            return sum1;
        }
        for (int i = 0; i < k-1; i++) {
            int b = a;
            int num = 0;
            while (b > 0) {
                num += (b % 10);
                b /= 10;
            }
            a = num;

        }
        return a;
    }
}